import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;

/**
 * 
 * @author vtapcov
 * 
 */
public class PlayerReader {

	public static String readFile(String fileName) {
		Charset cp1251 = Charset.forName("Cp1251");
		Closeable stream=null;
		try {
			InputStream in = new FileInputStream(new File (fileName));
		    stream = in;
		      Reader reader = new InputStreamReader(in, cp1251);
		      stream = reader;
		      StringBuilder inputBuilder = new StringBuilder();
		      char[] buffer = new char[1024];
		      while (true) {
		        int readCount = reader.read(buffer);
		        if (readCount < 0) {
		          break;
		        }
		        inputBuilder.append(buffer, 0, readCount);
		      }
		      return inputBuilder.toString();
		} catch (IOException e1) {
			e1.printStackTrace();
		} finally {
		      try {
		    	  if (stream!=null){
				stream.close();}
			} catch (IOException e) {
				e.printStackTrace();
			}
	    }
		return null;
	}
}
